<extend name="Base/base" />
<block name='head'>
    <meta charset="utf-8">
    <link href="/Public/static/dropload/dropload.css" rel="stylesheet" />
    <!--<link href="/Public/Index/css/page.css" rel="stylesheet" />-->
    <link href="/Public/Index/css/workflow.css" rel="stylesheet" /> 
</block>
<block name="content" > 
    <div class="transferred_table">
        <table border="1">
            <notempty name="news">
                <foreach name="news" item="new">
                    <tr>
                        <td style='text-align:left;'>
                            <a href="{:U('show',array('news_id'=>$new['news_id']))}" title="{$new.subject}">{$new.subject}</a>
                        </td>
                        <!--<td>{$new.news_time}</td>-->
                        <td width='20%'><a href="{:U('addNews',array('news_id'=>$new['news_id']))}">修&nbsp;改</a>&nbsp;&nbsp;|&nbsp;&nbsp;
                            <a href="#" class='pointer delNews' data-id="{$new.news_id}"> 删&nbsp;除</a></td>

                    </tr>
                </foreach>
            <else />
                <tr><td colspan="5" style="text-align: left">暂无数据</td></tr>
            </notempty>
        </table>
        <!--<div class="page">{$pages}</div>-->
        <input type="hidden" id="url" value="{:U('dropload')}">
        <input type="hidden" id="delurl" value="{:U('News/delNews')}">
    </div>
    <div class="button">
        <a class="am-btn back" data-url="{:U('index')}">返 回</a>
    </div>
</block>
<block name="script">
    <script type="text/javascript" src="/Public/static/dropload/dropload.js" ></script>
    <script type="text/javascript" src="/Public/Index/js/form.js"></script>
    <script type="text/javascript">
        $('.back').on('click', function () {
            location.href = $(this).attr('data-url')
        })
        $(initDelNews());
        $(function () {
            p = 2;
            var dropload = $('.transferred_table').dropload({
                scrollArea: window,
                domDown: {
                    domClass: 'dropload-down',
                    domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
                    domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                    domNoData: '<div class="dropload-noData">已无数据</div>'
                },
                loadDownFn: function (me) {
                    var url = $('#url').val() + '?p=' + p ;
//                    alert(url);
                    p++;
                    $.ajax({
                        url: url,
                        type: 'get',
                        success: function (res) {
                            console.log(res)
//                            alert(res.length);
                            if (res.length > 0) {
                                var html = '';
                                for (var i = 0; i < res.length; i++) {
                                    html += '<tr><td width="70%" style="text-align:left"><a href="/index.php/Index/News/show/news_id/'+res[i].news_id+'.html">'+res[i].subject_info+'</a></td><td><a href="/index.php/Index/News/addNews/news_id/'+res[i].news_id+'.html">修&nbsp;改</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#" class="pointer delNews" data-id="'+res[i].news_id+'"> 删&nbsp;除</a></td></tr>';
                                }
                                $('.transferred_table tr:last').after(html);
                            } else {
                                me.noData();
                            }
                            me.resetload();
                        }
                    })
                }
            });
        })

    </script>
</block>
